<?php

/**
*	链接删除(物理删除)
*
*/


//包含公共文件
include '../../common/common.php';

//接收post传值
// var_dump($_POST);
$linkBtn = $_POST['linkBtn'];

//接收要删除数据的lid (关联数组)
$arrLid = $_POST['arr'];

//判断选项是否为空
if (!$arrLid) {
	exit('选项不得为空');
}

//将数组拼接成字符串
$strLid = join(',' , $arrLid);

// var_dump($arrLid);
// var_dump($strLid);


//物理删除
if ($linkBtn == '删 除') {

	//删除数据
	$resDel = myDelete($link , DB_TABLE_LINK , "lid in ($strLid)");
	// var_dump($resDel);

	//判断是否删除成功
	if (!$resDel) {

		exit('删除失败<br /> <a href="'  . $_SERVER['HTTP_REFERER'] .'">返回上一页</a>');
	}

	//页面跳转
	echo '删除成功';
	header('refresh:1;url=' . $_SERVER['HTTP_REFERER']);
}

//恢复显示
if ($linkBtn == '恢 复') { 

	$resUpdate = myUpdate($link , DB_TABLE_LINK , ['isdel' => 0], "lid in ($strLid)");
	// var_dump($resUpdate);

	//判断是否修改成功
	if  (!$resUpdate) {

		exit('恢复失败<br /> <a href="'  . $_SERVER['HTTP_REFERER'] .'">返回上一页</a>');
	}

	echo '恢复成功';
	header('refresh:1;url=' . $_SERVER['HTTP_REFERER']);
}